﻿using System;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Json;
using System.Xml.Serialization;

namespace StateTheater.Models
{
    [Serializable]
    [DataContract]
    public class Pair<F, S>
    {
        [DataMember]
        public F First { set; get; }
        [DataMember]
        public S Second { get; set; }

		protected Pair(SerializationInfo info, StreamingContext context)
		{
		}
		/// <summary>
		/// Initializes a new instance of the Pair class.
		/// </summary>
		public Pair(F first, S second)
		{
			First = first;
			Second = second;
		}

	/// <summary>
		/// Initializes a new instance of the Pair class.
		/// </summary>
		public Pair()
		{
		}

		#region Json & Xml Output methods
		public void JsonOutput(System.IO.Stream stream)
        {
            DataContractJsonSerializer serializer2 = new DataContractJsonSerializer(typeof(Pair<F, S>));
            serializer2.WriteObject(stream, this);
        }
        public static void JsonArrayOutput(System.IO.Stream stream, Pair<F, S>[] pairs)
        {
            DataContractJsonSerializer serializer2 = new DataContractJsonSerializer(typeof(Pair<F, S>[]));
            serializer2.WriteObject(stream, pairs);
        }

        public void XmlOutput(System.IO.Stream stream)
        {
            XmlSerializer serializer2 = new XmlSerializer(typeof(Pair<F, S>));
            serializer2.Serialize(stream, this);
        }
        public static void XmlArrayOutput(System.IO.Stream stream, Pair<F, S>[] pairs)
        {
            XmlSerializer serializer2 = new XmlSerializer(typeof(Pair<F, S>[]));
            serializer2.Serialize(stream, pairs);
        }
        #endregion
    }
}
